package com.sugon.entity;

import cn.hutool.core.util.NumberUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 *
 * 固定资产
 *
 * @Description: fixed_assets
 * @author: YuXD
 * @since: 2023-06-27
 */
@Data
public class FixedAssets implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * id
     */
    private String id;
    /**
     * 资产名称
     */
    private String assetsName;
    /**
     * ERP资产编号
     */
    private String erpAssetsNumber;

    /**
     * 固定资产编码
     */
    private String code;

    /**
     * 资产状态
     */
    private String state;
    /**
     * 使用部门
     */
    private String userDepartment;
    /**
     * 创建日期
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date createTime;
    /**
     * 更新日期
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date updateTime;
    /**
     * 原值
     */
    private BigDecimal originVal;

    /**
     * 净值
     */
    private BigDecimal netWorth;

    public BigDecimal getNetWorth() {
        if (this.originVal != null && this.deprnReserve != null) {
            return NumberUtil.sub(this.originVal, this.deprnAmount);
        }
        return null;
    }

    /**
     * 启用日期
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date openingDate;
    /**
     * 关联设备
     */
    private String devId;
    /**
     * 大类
     */
    private String fcbSegment1;
    /**
     * 小类
     */
    private String fcbSegment2;
    /**
     * 月折旧
     */
    private Integer deprnAmount;
    /**
     * 累计折旧
     */
    private Integer deprnReserve;
    /**
     * 开始折旧日期
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date deprnStartDate;
    /**
     * 残值率
     */
    private String lived;
    /**
     * 使用年限
     */
    private Integer lifeInMonths;

}
